package cn.springcloud.alibaba.core.util;

import com.alibaba.fastjson.JSON;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class ResponseUtil {

	public static void outputJsonResponse(HttpServletResponse response, Object obj) throws IOException {
		response.setStatus(200);
		response.setCharacterEncoding("utf-8");
		response.setContentType("application/json; charset=utf-8");
		PrintWriter writer = response.getWriter();
		writer.write(JSON.toJSONString(obj));
		writer.flush();
		writer.close();
	}
}
